package io.renren.modules.hos.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.hos.entity.PrescribeEntity;
import io.renren.modules.hos.service.PrescribeService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author ryf
 * @email 2559228480@qq.com
 * @date 2021-11-10 16:10:52
 */
@RestController
@RequestMapping("hos/prescribe")
public class PrescribeController {
    @Autowired
    private PrescribeService prescribeService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("hos:prescribe:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = prescribeService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{prescribeId}")
    @RequiresPermissions("hos:prescribe:info")
    public R info(@PathVariable("prescribeId") Long prescribeId){
		PrescribeEntity prescribe = prescribeService.getById(prescribeId);

        return R.ok().put("prescribe", prescribe);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("hos:prescribe:save")
    public R save(@RequestBody PrescribeEntity prescribe){
		prescribeService.save(prescribe);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("hos:prescribe:update")
    public R update(@RequestBody PrescribeEntity prescribe){
		prescribeService.updateById(prescribe);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("hos:prescribe:delete")
    public R delete(@RequestBody Long[] prescribeIds){
		prescribeService.removeByIds(Arrays.asList(prescribeIds));

        return R.ok();
    }

}
